活动
最新
False
生产力活动
Last updated 2024年7月1日

Google 云端硬盘 API

创建 Google 云端硬盘服务。

命名空间:UiPath.Gsuite.Activities.API

程序集:UiPath.Gsuite.Activities.API(在 UiPath.Gsuite.Activities.API.dll 中)

构造函数

构造函数描述语法
Google 云端硬盘服务初始化 GoogleDriveService 类的新实例
public class GoogleDriveService : IGoogleDriveServicepublic class GoogleDriveService : IGoogleDriveService

方法

名称描述
应用文件标签将 Google 云端硬盘标签应用于指定文件。
清除文件标签字段从文件中删除一个或多个标签字段。
复制文件复制指定 Google 云端硬盘位置上的文件。
创建文件夹在指定的 Google 云端硬盘位置创建文件夹。
删除项目删除指定的文件或文件夹。
下载文件下载指定的文件。
获取云端硬盘标签获取包含空字段的云端硬盘标签。
获取文件通过相对路径、URL、ID 或完整路径从 Google 云端硬盘获取文件。
获取文件标签从指定的 Google 云端硬盘位置检索文件列表。
获取文件从指定的 Google 云端硬盘位置检索文件列表。
获取文件和文件夹从指定的 Google 云端硬盘位置检索文件和文件夹列表。
获取文件夹

通过相对路径或者通过 URL、ID 或完整路径从 Google 云端硬盘获取文件夹。

获取文件夹从指定的 Google 云端硬盘位置检索文件夹列表。
获取项目

通过相对路径、URL、ID 或完整路径从 Google 云端硬盘获取文件或文件夹。

移动文件将文件夹移动到 Google 云端硬盘中的指定目标文件夹。
移动文件夹将文件夹移动到 Google 云端硬盘中的指定目标文件夹。
刷新文件获取指定文件的最新版本。
刷新文件夹获取指定文件夹的最新版本。
刷新项目获取指定文件或文件夹的最新版本。
删除文件标签从文件中删除标签。
共享文件

与任何人、域或指定收件人共享文件。

共享文件夹

与任何人、域或指定收件人共享文件夹。

上传文件将文件上传至 Google 云端硬盘
上传文件将文件上传至 Google 云端硬盘。

示例

在以下示例中,您可以了解如何使用 API 通过添加后缀来重命名 Google 云端硬盘文件夹中的所有文件。
using GoogleWorkspaceCodedWorkflows.ObjectRepository;
using System;
using System.Collections.Generic;
using System.Data;
using UiPath.CodedWorkflows;
using UiPath.Core;
using UiPath.Core.Activities.Storage;
using UiPath.Excel;
using UiPath.Excel.Activities;
using UiPath.Excel.Activities.API;
using UiPath.Excel.Activities.API.Models;
using UiPath.GSuite.Activities.Api;
using UiPath.Mail.Activities.Api;
using UiPath.Orchestrator.Client.Models;
using UiPath.Testing;
using UiPath.Testing.Activities.TestData;
using UiPath.Testing.Activities.TestDataQueues.Enums;
using UiPath.Testing.Enums;
using UiPath.UIAutomationNext.API.Contracts;
using UiPath.UIAutomationNext.API.Models;
using UiPath.UIAutomationNext.Enums;

namespace GoogleWorkspaceCodedWorkflows
{
    public class Rename_all_the_files_in_a_Google_Drive_folder : CodedWorkflow
    {
        [Workflow]
        public void Execute(string NameSubfix)
        {
           var service = google.Drive(connections.Drive.<connectionID>);
            
            var folderUrl ="https://drive.google.com/drive/folders/1sE7UqjderUPv24Rxkto5jyefAuVLeVCz";
            var folder = service.GetFolder(folderUrl,IdentificationType.UrlOrId);
            var files = service.GetFiles(folder);
            foreach (var file in files)
            {
                System.Console.WriteLine(file.FullName);
                file.Move(folder,file.FullName+"-"+NameSubfix,ConflictBehavior.Replace);
                
            }
        }
    }
}using GoogleWorkspaceCodedWorkflows.ObjectRepository;
using System;
using System.Collections.Generic;
using System.Data;
using UiPath.CodedWorkflows;
using UiPath.Core;
using UiPath.Core.Activities.Storage;
using UiPath.Excel;
using UiPath.Excel.Activities;
using UiPath.Excel.Activities.API;
using UiPath.Excel.Activities.API.Models;
using UiPath.GSuite.Activities.Api;
using UiPath.Mail.Activities.Api;
using UiPath.Orchestrator.Client.Models;
using UiPath.Testing;
using UiPath.Testing.Activities.TestData;
using UiPath.Testing.Activities.TestDataQueues.Enums;
using UiPath.Testing.Enums;
using UiPath.UIAutomationNext.API.Contracts;
using UiPath.UIAutomationNext.API.Models;
using UiPath.UIAutomationNext.Enums;

namespace GoogleWorkspaceCodedWorkflows
{
    public class Rename_all_the_files_in_a_Google_Drive_folder : CodedWorkflow
    {
        [Workflow]
        public void Execute(string NameSubfix)
        {
           var service = google.Drive(connections.Drive.<connectionID>);
            
            var folderUrl ="https://drive.google.com/drive/folders/1sE7UqjderUPv24Rxkto5jyefAuVLeVCz";
            var folder = service.GetFolder(folderUrl,IdentificationType.UrlOrId);
            var files = service.GetFiles(folder);
            foreach (var file in files)
            {
                System.Console.WriteLine(file.FullName);
                file.Move(folder,file.FullName+"-"+NameSubfix,ConflictBehavior.Replace);
                
            }
        }
    }
}
在以下示例中,您可以了解如何使用 API 读取文件夹(包括子文件夹)中的所有文件。
using GoogleWorkspaceCodedWorkflows.ObjectRepository;
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using UiPath.CodedWorkflows;
using UiPath.Core;
using UiPath.Core.Activities.Storage;
using UiPath.Excel;
using UiPath.Excel.Activities;
using UiPath.Excel.Activities.API;
using UiPath.Excel.Activities.API.Models;
using UiPath.GSuite.Activities.Api;
using UiPath.GSuite.Drive.Models;
using UiPath.Mail.Activities.Api;
using UiPath.Orchestrator.Client.Models;
using UiPath.Testing;
using UiPath.Testing.Activities.TestData;
using UiPath.Testing.Activities.TestDataQueues.Enums;
using UiPath.Testing.Enums;
using UiPath.UIAutomationNext.API.Contracts;
using UiPath.UIAutomationNext.API.Models;
using UiPath.UIAutomationNext.Enums;

namespace GoogleWorkspaceCodedWorkflows
{
    public class ReadAllFilesFromAFolder : CodedWorkflow
    {
        [Workflow]
        public void Execute()
        {            
            var service = google.Drive(connections.Drive.<connectionID>);     
         
            // Read All files from Google Drive and its subfolders 
            readFilesInAFolder(null,service);
            
        }
        // Read All files from a Folder including all subfolders
        public void readFilesInAFolder(IFolder? googleFolder, IGoogleDriveService service)
        {
            var filesAndFolders = service.GetFilesAndFolders(googleFolder);
        
            foreach (var fileFolder in filesAndFolders.OrderBy(f=> f.IsFolder))
            {
                if(!fileFolder.IsFolder)
                {
                    var folder = service.GetFolder(fileFolder.Item.ParentId);
                    
                    Log("Folder: "+ folder.FullName+" FileName: "+fileFolder.FullName+ " Type: "+fileFolder.Item.MimeType);
                }
                else
                {
                    readFilesInAFolder(fileFolder as IFolder, service);
                }
            }
            
        }
    }
    
}using GoogleWorkspaceCodedWorkflows.ObjectRepository;
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using UiPath.CodedWorkflows;
using UiPath.Core;
using UiPath.Core.Activities.Storage;
using UiPath.Excel;
using UiPath.Excel.Activities;
using UiPath.Excel.Activities.API;
using UiPath.Excel.Activities.API.Models;
using UiPath.GSuite.Activities.Api;
using UiPath.GSuite.Drive.Models;
using UiPath.Mail.Activities.Api;
using UiPath.Orchestrator.Client.Models;
using UiPath.Testing;
using UiPath.Testing.Activities.TestData;
using UiPath.Testing.Activities.TestDataQueues.Enums;
using UiPath.Testing.Enums;
using UiPath.UIAutomationNext.API.Contracts;
using UiPath.UIAutomationNext.API.Models;
using UiPath.UIAutomationNext.Enums;

namespace GoogleWorkspaceCodedWorkflows
{
    public class ReadAllFilesFromAFolder : CodedWorkflow
    {
        [Workflow]
        public void Execute()
        {            
            var service = google.Drive(connections.Drive.<connectionID>);     
         
            // Read All files from Google Drive and its subfolders 
            readFilesInAFolder(null,service);
            
        }
        // Read All files from a Folder including all subfolders
        public void readFilesInAFolder(IFolder? googleFolder, IGoogleDriveService service)
        {
            var filesAndFolders = service.GetFilesAndFolders(googleFolder);
        
            foreach (var fileFolder in filesAndFolders.OrderBy(f=> f.IsFolder))
            {
                if(!fileFolder.IsFolder)
                {
                    var folder = service.GetFolder(fileFolder.Item.ParentId);
                    
                    Log("Folder: "+ folder.FullName+" FileName: "+fileFolder.FullName+ " Type: "+fileFolder.Item.MimeType);
                }
                else
                {
                    readFilesInAFolder(fileFolder as IFolder, service);
                }
            }
            
        }
    }
    
}
  • 构造函数
  • 方法
  • 示例

此页面是否有帮助?

获取您需要的帮助
了解 RPA - 自动化课程
UiPath Community 论坛
Uipath 白色徽标
信任与安全
© 2005-2024 UiPath. All rights reserved.